﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VideoNetApplication.Common.Dao
{
  public  class TeacherDao
    {

        /// <summary>
        /// 获取所有老师
        /// </summary>
        /// <param name="schoolId"></param>
        /// <param name="startIndex"></param>
        /// <param name="maxRows"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
      public List<V_teacher> GetTeacherByALL(int schoolId, int startIndex, int maxRows, out int recordCount)
      {
          using (EVDBEntities edm = new EVDBEntities())
          {
              recordCount = edm.V_teacher.Where(s => s.SchoolID == schoolId && s.VT_IsEnable == 1).Count();
              return
                  edm.V_teacher.Where(s => s.SchoolID == schoolId&&s.VT_IsEnable==1).OrderByDescending(m => m.ID).Skip(startIndex - 1).Take(maxRows)
                      .ToList();
          }

      }

      /// <summary>
      /// 获取一个老师
      /// </summary>
      /// <param name="tid"></param>
      /// <param name="schoolId"></param>
      /// <returns></returns>
      public V_teacher GetTeacherByID(int tid, int schoolId)
      {
          using (EVDBEntities edm = new EVDBEntities())
          {
              return edm.V_teacher.FirstOrDefault(s => s.ID == tid && s.SchoolID == schoolId);
          }

      }
    }
}
